package com.novabluetooth.data;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.health.httpbean.upload.TjDataUpload;
import com.health.tablebean.SBCL_DATA_NEW;
import com.health.tools.ArithmeticUtils;
import com.health.viewscontrols.NovaApplication;
import com.health.tablebean.SBCL_DATA;
import com.health.viewscontrols.medical.base.DeviceEnum;
import com.novabluetooth.services.BluetoothConstant;
import com.novabluetooth.services.ktxyj.Constants;
import com.novabluetooth.views.twj.TwjConstans;
import com.peng.ppscalelibrary.BleManager.Model.LFPeopleGeneral;

import android.text.TextUtils;
import android.util.Log;

/**
 * 保存并显示设备数据
 * 
 * @author nova BlueToothData
 */
public class DeviceShowSaveData {
	private static final String TAG = "DeviceShowSaveData";
	static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	static String str_result = "";// 显示结果
	static String devicename = "";// 设备名称
	static String IDCARD = "";
	static String uroString;
	static String bloString;
	static String bilString;
	static String ketString;
	static String leuString;
	static String gluString;
	static String proString;
	static String phString;
	static String nitString;
	static String sgString;
	static String ascString;

	public static String getDataShow(String data, String deviceName) {
		System.out.println(deviceName + ":deviceName");
		Log.e("xiaoxin","data:" + data + "deviceName:" + deviceName);
		str_result = "";
		try {
			IDCARD = NovaApplication.getUserInfo().getIDCARD();
			Log.e(TAG, "获取结果--" + IDCARD);
			if (TextUtils.isEmpty(IDCARD)) {
				return "";
			}

			devicename = deviceName;
			switch (deviceName) {
				case "SP70B":
					// 存血糖
					saveCLData("肺功能", "肺功能", "肺功能", data, "肺功能", UUID.randomUUID().toString(), IDCARD,
							df.format(new Date()));
					break;
			case BluetoothConstant.XUEYANG_NOVA:
				// 诺安血氧
				if (data.contains(";")) {
					String xueyangbaohedu = data.split(";")[0].toString();
					String mailv = data.split(";")[1].toString();
					str_result = "血氧：" + xueyangbaohedu + "%        " + "脉率：" + mailv + "bpm";

					if (!checkData("血氧", xueyangbaohedu + "%")) {
						return str_result;
					}

					UUID uuid = UUID.randomUUID();
					String date = df.format(new Date());
					// 存血氧
					saveCLData("诺安血氧仪", "血氧仪", "血氧", xueyangbaohedu + "%", "血氧", uuid.toString(), IDCARD, date);
					// 存脉率
					saveCLData("诺安血氧仪", "血氧仪", "脉率", mailv + "bpm", "脉率", uuid.toString(), IDCARD, date);
					// HealthTiJian_YbqkFragment.showML(mailv);
				}
				break;
			case BluetoothConstant.XUETANG_AMX_SANNUO:
				// 诺安血糖
				// data="20.11";
				str_result = "血糖：" + data + "mmol/L";
				if (!checkData("血糖", data + "mmol/L")) {
					return str_result;
				}

				UUID uuidXueTang = UUID.randomUUID();
				String dateXueTang = df.format(new Date());
				// 存血糖
				saveCLData("诺安血糖仪", "血糖仪", "血糖", data + "mmol/L", "血糖", uuidXueTang.toString(), IDCARD, dateXueTang);
				Log.e("tag", "测量血糖");
				// HealthTiJian_FzjcFragment.showXuetang(data);
				break;
			case BluetoothConstant.XUETANG_WL_1_SANNUO:
				// 三诺血糖
				str_result = "血糖：" + data + "mmol/L";
				if (!checkData("血糖", data + "mmol/L")) {
					return str_result;
				}

				UUID uuidsanNuoXueTang = UUID.randomUUID();
				String datesanNuoXueTang = df.format(new Date());
				// 存血糖
				saveCLData("三诺血糖仪", "血糖仪", "血糖", data + "mmol/L", "血糖", uuidsanNuoXueTang.toString(), IDCARD,
						datesanNuoXueTang);
				// HealthTiJian_FzjcFragment.showXuetang(data);
				break;
			case BluetoothConstant.XUETANG_YUYUE760_YUYUE:
				// 鱼跃760血糖仪
				str_result = "血糖：" + data + "mmol/L";
				if (!checkData("血糖", data + "mmol/L")) {
					return str_result;
				}

				System.out.println(str_result);
				UUID uuidYuYueXueTang = UUID.randomUUID();
				String dateYuYueXueTang = df.format(new Date());
				// 存血糖
				saveCLData("鱼跃760血糖仪", "血糖仪", "血糖", data + "mmol/L", "血糖", uuidYuYueXueTang.toString(), IDCARD,
						dateYuYueXueTang);

				break;
			case BluetoothConstant.XUEZHI_CARDIOCHEK:

				//卡迪克血脂仪
//				if(data.contains(",")){
					//血脂结果
//					String reData = data.split(",")[0].toString();
					//测量时间
//					String reDate = data.split(",")[1].toString();
					str_result =  data ;

					if (!checkData("血脂", data)) {
						return str_result;
					}
					UUID uuidXueZhiYi = UUID.randomUUID();
					String dateXueZhiYi = df.format(new Date());
					//存血脂
					saveCLData("卡迪克血脂仪","血脂仪","血脂",data,"血脂",
                            uuidXueZhiYi.toString(), IDCARD,
							dateXueZhiYi);
//				}

				break;
				case BluetoothConstant.PW_01DEVICE_NAME:
					//存血脂
					String dateErWenxz = df.format(new Date());
					saveCLData("e家医护血脂","血脂4项","血脂",data,BluetoothConstant.PW_01DEVICE_NAME,
							dateErWenxz.toString(), IDCARD,
							dateErWenxz);

					break;
				case TwjConstans.DEVICE_NAME:
					//倍泰额温枪
					str_result = "体温：" + data + "℃";
					if (!checkData("体温", data + "℃")) {
						return str_result;
					}

					UUID uuidEWen3 = UUID.randomUUID();
					String dateEWen3 = df.format(new Date());
					// 存体温
					saveCLData("爱奥乐红外体温计", "红外体温计", "体温",
							data + "℃", "体温", uuidEWen3.toString(), IDCARD, dateEWen3);
					break;
			case BluetoothConstant.TIWEN_EWQ_NOVA:
				// 诺安耳温枪体温
				str_result = "体温：" + data + "℃";
				if (!checkData("体温", data + "℃")) {
					return str_result;
				}

				UUID uuidErWen = UUID.randomUUID();
				String dateErWen = df.format(new Date());
				// 存体温
				saveCLData("诺安耳温枪", "耳温枪", "体温", data + "℃", "体温", uuidErWen.toString(), IDCARD, dateErWen);
				// HealthTiJian_YbqkFragment.showTW(data);
				break;
				case BluetoothConstant.EWENQIANG:
					//倍泰额温枪
					str_result = "体温：" + data + "℃";
					if (!checkData("体温", data + "℃")) {
						return str_result;
					}

					UUID uuidEWen2 = UUID.randomUUID();
					String dateEWen2 = df.format(new Date());
					// 存体温
					saveCLData("倍泰额温枪", "额温枪", "体温", data + "℃", "体温", uuidEWen2.toString(), IDCARD, dateEWen2);

					break;
			case BluetoothConstant.TIWEN_EWENQ_HTD2:
				// 诺安耳温枪体温
				str_result = "体温：" + data + "℃";
				if (!checkData("体温", data + "℃")) {
					return str_result;
				}

				UUID uuidErWen2 = UUID.randomUUID();
				String dateErWen2 = df.format(new Date());
				// 存体温
				saveCLData("和泰达耳温枪", "耳温枪", "体温", data + "℃", "体温", uuidErWen2.toString(), IDCARD, dateErWen2);
				// HealthTiJian_YbqkFragment.showTW(data);
				break;
			case BluetoothConstant.TIZHONG_NOVA:
				// 诺安体重秤
				str_result = "体重：" + data + "Kg";
				if (!checkData("体重", data + "Kg")) {
					return str_result;
				}

				UUID uuidTiZhong = UUID.randomUUID();
				String dateTiZhong = df.format(new Date());
				// 存体重
				saveCLData("诺安体重秤", "体重秤", "体重", data + "Kg", "体重", uuidTiZhong.toString(), IDCARD, dateTiZhong);
				// HealthTiJian_YbqkFragment.showTZ(data);
				break;
			case BluetoothConstant.TIZHONG_FATSCALE:
				// 诺安体重秤
				str_result = "体重：" + data + "Kg";
				if (!checkData("体重", data + "Kg")) {
					return str_result;
				}

				UUID uuidTiZhongFat = UUID.randomUUID();
				String dateTiZhongFat = df.format(new Date());
				// 存体重
				saveCLData("脂肪秤", "脂肪秤", "体重", data + "Kg", "体重", uuidTiZhongFat.toString(), IDCARD, dateTiZhongFat);
				break ;
				case BluetoothConstant.TIZHONG_HEALTH:
					// 诺安体重秤 轻加体脂秤
					str_result = "体重：" + data + "Kg";
					if (!checkData("体重", data + "Kg")) {
						return str_result;
					}

					UUID uuidTiZhongHealth = UUID.randomUUID();
					String dateTiZhongHealth = df.format(new Date());
					// 存体重
					if (!TextUtils.isEmpty(data)) {
						saveCLData("脂肪秤", "轻加脂肪秤", "体重", data + "Kg", "体重", uuidTiZhongHealth.toString(), IDCARD, dateTiZhongHealth);
					}
					break ;
				case BluetoothConstant.BEITAITIZHONG:
					// 诺安体重秤
					str_result = "体重：" + data + "Kg";
					if (!checkData("体重", data + "Kg")) {
						return str_result;
					}

					UUID uuidTiZhongHealth2 = UUID.randomUUID();
					String dateTiZhongHealth2 = df.format(new Date());
					// 存体重
					saveCLData("体脂秤", "体脂秤", "体重", data + "Kg", "体重", uuidTiZhongHealth2.toString(), IDCARD, dateTiZhongHealth2);
					break;
			case BluetoothConstant.XUEYA_JMR:
				setXueYaJiData(data, "捷美瑞血压仪");
				break;
			case BluetoothConstant.XUEYA_JMR2:
				setXueYaJiData(data, "捷美瑞血压仪");
				break;
			case BluetoothConstant.XUEYA_KANGTAI:
				// 康泰08A血压计
				setKTXueYaJiData(data);
				break;
			case BluetoothConstant.XUEHONGDANBAI_NOVA:
				// 易捷血红蛋白仪
				String xuehoangBuffer[] = data.split("\r\n");
				str_result = "血红蛋白：" + xuehoangBuffer[2].substring(8);

				if (!checkData("血红蛋白", xuehoangBuffer[2].substring(8).toString())) {
					return str_result;
				}
				UUID uuidYJXuehongdanbai = UUID.randomUUID();
				String dateYJXuehongdanbai = df.format(new Date());
				// 存血红蛋白
				saveCLData("易捷血红蛋白仪", "血红蛋白仪", "血红蛋白", xuehoangBuffer[2].substring(8), "血红蛋白",
						uuidYJXuehongdanbai.toString(), IDCARD, dateYJXuehongdanbai);
				break;
			case BluetoothConstant.NIAOJI_HT111A_HANTANG:
				String niaoYeBuffer[] = data.split(",");
				getNiaoYe(niaoYeBuffer);
				break;
			case BluetoothConstant.TIWEN_EWQ_HTD:
				setEWdata(data, BluetoothConstant.TIWEN_EWQ_HTD);
				break;
			case BluetoothConstant.TIWEN_EWENQ_HTD:
				setEWdata(data, BluetoothConstant.TIWEN_EWENQ_HTD);
				break;
				case BluetoothConstant.TIWEN_EWENQ_HTD3:
					setEWdata(data, BluetoothConstant.TIWEN_EWENQ_HTD);
					break;
			case BluetoothConstant.XUEYA_YOURIEN:
				// 优瑞恩血压
				setXueYaJiData(data, "优瑞恩血压仪");
				break;
			case BluetoothConstant.XUEYA_YE680A_YUYUE:
				// 鱼跃血压
				setXueYaJiData(data, "鱼跃血压仪");
				break;
				case BluetoothConstant.XUEYA_YE680A_YUYUE2:
					// 鱼跃血压
					setXueYaJiData(data, "鱼跃血压仪");
					break;
			case BluetoothConstant.XUEYANG_BM:
				// 贝瑞血氧
				if (data.contains(";")) {
					String xueyangbaohedu = data.split(";")[0].toString();
					String mailv = data.split(";")[1].toString();
					str_result = "血氧：" + xueyangbaohedu + "%        " + "脉率：" + mailv + "bpm";

					if (!checkData("血氧", xueyangbaohedu + "%")) {
						return str_result;
					}
					UUID uuid = UUID.randomUUID();
					String date = df.format(new Date());
					// 存血氧
					saveCLData("贝瑞血氧仪", "血氧仪", "血氧", xueyangbaohedu + "%", "血氧", uuid.toString(), IDCARD, date);
					// 存脉率
					saveCLData("贝瑞血氧仪", "血氧仪", "脉率", mailv + "bpm", "脉率", uuid.toString(), IDCARD, date);
					// HealthTiJian_YbqkFragment.showML(mailv);
				}
				break;
			case BluetoothConstant.XUEYANG_LIKANG_KRK:
				String xueyang = "";
				String mailv = "";
				if (data.contains("/")) {
					xueyang = data.split("/")[0];
					mailv = data.split("/")[1];
					str_result = "血氧：" + xueyang + "%        " + "脉率：" + mailv + "bpm";

					if (!checkData("血氧", xueyang + "%")) {
						return str_result;
					}

					UUID uuid = UUID.randomUUID();
					String date = df.format(new Date());
					// 存血氧
					saveCLData("科瑞康血氧仪", "血氧仪", "血氧", xueyang + "%", "血氧", uuid.toString(), IDCARD, date);
					// 存脉率
					saveCLData("科瑞康血氧仪", "血氧仪", "脉率", mailv + "bpm", "脉率", uuid.toString(), IDCARD, date);
					// HealthTiJian_YbqkFragment.showML(mailv);
				}
				break;
				case "BeneCheck":
					//百捷三合一
//					if (data.contains(";")) {
					if (!TextUtils.isEmpty(data)) {
						String  signFlagName="";
						signFlagName = "血糖";
						String dataUnit="mmol/L";
						dataUnit = "mmol/L";
						UUID uuid = UUID.randomUUID();
						String date = df.format(new Date());
						Log.e(TAG,"存血糖");
						try {
							List<SBCL_DATA> list1 = NovaApplication.fdbmanger.findAllByWhere(SBCL_DATA.class,
									"IDCARD = '" + IDCARD + "' AND CL_TYPE_NAME = '血糖' ORDER BY CL_TIME DESC LIMIT 1");
							if(list1 == null || list1.size() <= 0) {
								saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
										signFlagName, data + dataUnit, signFlagName, uuid.toString(), IDCARD, date);
							}else {
								SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								Date clDate = format.parse(list1.get(0).getCL_TIME());
								long diffTime = (System.currentTimeMillis() - clDate.getTime())/1000;
								if (diffTime > 25) { //数据库数据 时间和当前时间相差15秒 录入数据
									saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
											signFlagName, data + dataUnit, signFlagName, uuid.toString(), IDCARD, date);
								}
							}
						} catch (ParseException e) {
							e.printStackTrace();
							saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
									signFlagName, data + dataUnit, signFlagName, uuid.toString(), IDCARD, date);
						}
					}
					break;
				case "BeneCheck-ns":
					//百捷三合一 尿酸
					if (!TextUtils.isEmpty(data)) {
						try {
							List<SBCL_DATA> list1 = NovaApplication.fdbmanger.findAllByWhere(SBCL_DATA.class,
									"IDCARD = '" + IDCARD + "' AND CL_TYPE_NAME = '尿酸' ORDER BY CL_TIME DESC LIMIT 1");
							if(list1 == null || list1.size() <= 0) {
								saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
										"尿酸", data + "μmol/L", "尿酸", UUID.randomUUID().toString(),
										IDCARD,  df.format(new Date()));
							} else {
								SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								Date clDate = format.parse(list1.get(0).getCL_TIME());
								long diffTime = (System.currentTimeMillis() - clDate.getTime())/1000;
								if (diffTime > 20) {//数据库数据 时间和当前时间相差25秒 录入数据
									saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
											"尿酸", data + "μmol/L", "尿酸", UUID.randomUUID().toString(),
											IDCARD,  df.format(new Date()));
								}
							}
						} catch (ParseException e) {
							e.printStackTrace();
							saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
									"尿酸", data + "μmol/L", "尿酸", UUID.randomUUID().toString(),
									IDCARD,  df.format(new Date()));
						}
					}
					break;
				case "BeneCheck-dgc":
					//百捷三合一 胆固醇
					if (!TextUtils.isEmpty(data)) {
						saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
								"胆固醇", data + "mmol/L", "胆固醇", UUID.randomUUID().toString(),
								IDCARD,  df.format(new Date()));
						try {
							List<SBCL_DATA> list1 = NovaApplication.fdbmanger.findAllByWhere(SBCL_DATA.class,
									"IDCARD = '" + IDCARD + "' AND CL_TYPE_NAME = '胆固醇' ORDER BY CL_TIME DESC LIMIT 1");
							if(list1 == null || list1.size() <= 0) {
								saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
										"胆固醇", data + "mmol/L", "胆固醇", UUID.randomUUID().toString(),
										IDCARD,  df.format(new Date()));
							} else {
								SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								Date clDate = format.parse(list1.get(0).getCL_TIME());
								long diffTime = (System.currentTimeMillis() - clDate.getTime())/1000;
								if (diffTime > 20) {//数据库数据 时间和当前时间相差25秒 录入数据
									saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
											"胆固醇", data + "mmol/L", "胆固醇", UUID.randomUUID().toString(),
											IDCARD,  df.format(new Date()));
								}
							}
						} catch (ParseException e) {
							e.printStackTrace();
							saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME,
									"胆固醇", data + "mmol/L", "胆固醇", UUID.randomUUID().toString(),
									IDCARD,  df.format(new Date()));
						}
					}
					break;
				case "BeneCheck-xhdb":
					saveCLData("百捷三合一", "BeneCheck-xhdb",
							"血红蛋白", data + "g/dL", "血红蛋白", UUID.randomUUID().toString(),
							IDCARD,  df.format(new Date()));
					break;
				case "LYSUN BHM-101":
					//百捷三合一 胆固醇
					saveCLData("e家血红蛋白", "LYSUN BHM-101",
							"血红蛋白", data + "g/dL", "血红蛋白", UUID.randomUUID().toString(),
							IDCARD,  df.format(new Date()));
					break;
				case BluetoothConstant.BENECHECK_TRIPLE:
					//百捷三合一
					String signFlag = "";
					String resultData = "";
					if (data.contains(";")) {
						signFlag = data.split(";")[0].toString();
						resultData = data.split(";")[1].toString();

						String  signFlagName="";
							if(BluetoothConstant.TRIPLE_DATA_GLUC.equals(signFlag)){
								//41代表血糖,血糖的单位换算：mg/dl÷18=mmol/L
								//24 50 43 4C 41 00 00 00 09 00 00 00 0D 01 01 05 0E 78 00 C3
								signFlagName = "血糖";
							}else if(BluetoothConstant.TRIPLE_DATA_UA.equals(signFlag)){
								//51代表尿酸，胆固醇的单位换算：（mg/dl）x 0.02586 =（mmol/L).
								// 24 50 43 4C 51 00 00 00 09 00 00 00 0D 0C 03 0F 31 04 00 99
								signFlagName = "尿酸";
							}else if(BluetoothConstant.TRIPLE_DATA_CHOL.equals(signFlag)){
								//61代表胆固醇，尿酸的单位换算：mg/dl×59.5 = µmol/L；µmol/L/1000=mmol/L
								//24 50 43 4C 61 00 00 00 09 00 00 00 0D 01 01 05 29 79 00 FF
								signFlagName = "胆固醇";
							}else if(BluetoothConstant.TRIPLE_DATA_HB.equals(signFlag)){
								//E1代表血红蛋白
								signFlagName = "血红蛋白";
							}

						String dataUnit="mmol/L";
						if(BluetoothConstant.TRIPLE_DATA_HB.equals(signFlag)){
							//血红蛋白 惯用 g/dL
							dataUnit = "g/dL";
						}else{
							//血糖、尿酸、胆固醇 单位 mmol/L
							dataUnit = "mmol/L";
						}
						str_result =signFlagName+ "：" + resultData +dataUnit;

						if (!checkData(signFlagName, resultData +dataUnit)) {
							return str_result;
						}

						UUID uuid = UUID.randomUUID();
						String date = df.format(new Date());

						if(BluetoothConstant.TRIPLE_DATA_HB.equals(signFlag)){
							//血红蛋白 分开存储
							saveCLData(BluetoothConstant.TRIPLE_TYPENAME_HB, BluetoothConstant.TRIPLE_TYPENAME_HB, "血红蛋白", resultData + dataUnit, "血红蛋白",
									uuid.toString(), IDCARD, date);
						}else{
							// 三合一存值
							saveCLData(BluetoothConstant.TRIPLE_TYPENAME, BluetoothConstant.TRIPLE_TYPENAME, signFlagName, resultData + dataUnit, signFlagName, uuid.toString(), IDCARD, date);
						}
					}
					break;
				case BluetoothConstant.TW_JK:
					str_result = "体温：" + data + "℃";
					if (!checkData("体温", data + "℃")) {
						return str_result;
					}

					UUID uuidJK = UUID.randomUUID();
					String dateJK = df.format(new Date());
					// 存体温
					saveCLData("家康红外体温计", "体温计", "体温", data + "℃", "体温", uuidJK.toString(), IDCARD, dateJK);
					break;
				case "WAIST":
					//百捷三合一 胆固醇
					saveCLData("腰臀比", "WAIST",
							"腰臀比", data, "腰臀比", UUID.randomUUID().toString(),
							IDCARD,  df.format(new Date()));
					break;
				case "RTCF_DH":
					saveCLData("人体成分", "RTCF_DH",
							"RTCF_DH", data, "人体成分", UUID.randomUUID().toString(),
							IDCARD,  df.format(new Date()));
					break;
				case "FM2":
					saveCLData("DH身高体重", "FM2",
							"FM2", data, "FM2", UUID.randomUUID().toString(),
							IDCARD,  df.format(new Date()));
					break;
			default:
				break;
			}

		} catch (Exception e) {
			str_result = "";
		}
		return str_result;
	}

	public static String saveHealthScale(LFPeopleGeneral bodyDataModel,String weightStr) {
		IDCARD = NovaApplication.getUserInfo().getIDCARD();
		String json = GsonUtils.toJson(bodyDataModel);
		// 存体重
		saveCLData("脂肪秤", "轻加脂肪秤", "体重",
				json, "体重", UUID.randomUUID().toString(), IDCARD, df.format(new Date()));
		return str_result;
	}

	private static String setKTXueYaJiData(String data) {
		if (data.contains(";")) {
			String buffer_kt[] = data.split(";");
			str_result = "高压：" + buffer_kt[0].toString() + "mmHg" + ";低压:" + buffer_kt[1].toString() + "mmHg \n" + "脉率："
					+ buffer_kt[2].toString() + "次/分; \n平均压:" + buffer_kt[3].toString() + "mmHg";

			if (!checkData("高压", buffer_kt[0].toString() + "mmHg")) {
				return str_result;
			}
			UUID uuidJMRXueYa_kt = UUID.randomUUID();
			String dateJMRXueYa_kt = buffer_kt[4].toString();
			// 存高压
			saveCLData("康泰血压计08A-BT", "血压计", "高压", buffer_kt[0].toString() + "mmHg", "高压", uuidJMRXueYa_kt.toString(),
					IDCARD, dateJMRXueYa_kt);
			// 存低压
			saveCLData("康泰血压计08A-BT", "血压计", "低压", buffer_kt[1].toString() + "mmHg", "低压", uuidJMRXueYa_kt.toString(),
					IDCARD, dateJMRXueYa_kt);
			// 存脉率
			saveCLData("康泰血压计08A-BT", "血压计", "脉率", buffer_kt[2].toString() + "次/分", "脉率", uuidJMRXueYa_kt.toString(),
					IDCARD, dateJMRXueYa_kt);
			// 存平均压
			saveCLData("康泰血压计08A-BT", "血压计", "平均压", buffer_kt[3].toString() + "mmHg", "平均压", uuidJMRXueYa_kt.toString(),
					IDCARD, dateJMRXueYa_kt);
		} else {
			str_result = "";
		}
		return str_result;
	}

	/**
	 * 设置血压计数据
	 * 
	 * @param data
	 * @param type
	 * @return
	 * @author 王婷婷
	 * @date 2017年10月10日 下午4:20:39
	 */
	private static String setXueYaJiData(String data, String type) {
		if (data.contains(";")) {
			String xueYabuffer[] = data.split(";");
			str_result = "高压：" + xueYabuffer[0] + "mmHg" + "；  低压：" + xueYabuffer[1] + "mmHg \n        " + "心率："
					+ xueYabuffer[2] + "次/分";
			if (!checkData("高压", xueYabuffer[0] + "mmHg")) {
				return str_result;
			}
			System.out.println("xueYabuffer:" + xueYabuffer.length);

			UUID uuidYouRuiEnXueYa = UUID.randomUUID();
			String dateYouRuiEnXueYa = df.format(new Date());
			// 存高压
			saveCLData(type, "血压计", "高压", xueYabuffer[0] + "mmHg", "高压", uuidYouRuiEnXueYa.toString(), IDCARD,
					dateYouRuiEnXueYa);
			// 存低压
			saveCLData(type, "血压计", "低压", xueYabuffer[1] + "mmHg", "低压", uuidYouRuiEnXueYa.toString(), IDCARD,
					dateYouRuiEnXueYa);
			//存全血压
			saveCLData(type, "血压计", "血压", xueYabuffer[0]+"/"+xueYabuffer[1], "血压", uuidYouRuiEnXueYa.toString(), IDCARD,
					dateYouRuiEnXueYa);
			// 存心率
			saveCLData(type, "血压计", "脉率", xueYabuffer[2] + "次/分", "脉率", uuidYouRuiEnXueYa.toString(), IDCARD,
					dateYouRuiEnXueYa);
		} else {
			str_result = "";
		}
		return str_result;
	}

	/**
	 * 和泰达耳温枪、额温枪
	 * 
	 * @author 王婷婷
	 * @return
	 * @date 2017年2月13日 下午4:07:10
	 */
	private static String setEWdata(String data, String type) {
		if (data.length() < 10) {
			return "";
		}

		String biaozhi = data.substring(3, 5);
		String tiwen = data.substring(5, 9);
		System.out.println(tiwen + "**************");
		UUID uuidEWen = UUID.randomUUID();
		String dateEWen = df.format(new Date());
		if ("00".equals(biaozhi)) {
			str_result = "体温：" + tiwen + "℃";
			if (!checkData("体温", tiwen + "℃")) {
				return str_result;
			}
			if (BluetoothConstant.TIWEN_EWQ_HTD.equals(type)) {
				// 存体温
				saveCLData("和泰达耳温枪", "耳温枪", "体温", tiwen + "℃", "体温", uuidEWen.toString(), IDCARD, dateEWen);
			} else if (BluetoothConstant.TIWEN_EWENQ_HTD.equals(type)) {
				// 存体温
				saveCLData("和泰达额温枪", "额温枪", "体温", tiwen + "℃", "体温", uuidEWen.toString(), IDCARD, dateEWen);
			}
		} else if ("10".equals(biaozhi)) {
			str_result = "表面温度：" + tiwen + "℃";
			if (!checkData("表面温度", tiwen + "℃")) {
				return str_result;
			}

			if (BluetoothConstant.TIWEN_EWQ_HTD.equals(type)) {
				// 存表面温度
				saveCLData("和泰达耳温枪", "耳温枪", "表面温度", tiwen + "℃", "表面温度", uuidEWen.toString(), IDCARD, dateEWen);

			} else if (BluetoothConstant.TIWEN_EWENQ_HTD.equals(type)) {
				// 存表面温度
				saveCLData("和泰达额温枪", "额温枪", "表面温度", tiwen + "℃", "表面温度", uuidEWen.toString(), IDCARD, dateEWen);
			}

		}
		// HealthTiJian_YbqkFragment.showTW(tiwen);
		System.out.println("添加体温");
		return str_result;
	}

	public static String getNiaoYe(String[] niaoYeBuffer) {
		// TODO

		for (int i = 0; i < niaoYeBuffer.length; i++) {
			switch (i) {
			case 1:// 尿胆原
				int uro = Integer.parseInt(niaoYeBuffer[i]);
				if (uro == 0) {
					uroString = "-";
				} else if (uro == 1) {
					uroString = "+-";
				} else if (uro == 2) {
					uroString = "1+";
				} else if (uro == 3) {
					uroString = "2+";
				} else if (uro == 4) {
					uroString = "3+";
				}
				break;
			case 2:// 潜血
				int blo = Integer.parseInt(niaoYeBuffer[i]);
				if (blo == 0) {
					bloString = "-";
				} else if (blo == 1) {
					bloString = "+-";
				} else if (blo == 2) {
					bloString = "1+";
				} else if (blo == 3) {
					bloString = "2+";
				} else if (blo == 4) {
					bloString = "3+";
				}
				break;
			case 3:// 胆红素
				int bil = Integer.parseInt(niaoYeBuffer[i]);
				if (bil == 0) {
					bilString = "-";
				} else if (bil == 1) {
					bilString = "1+";
				} else if (bil == 2) {
					bilString = "2+";
				} else if (bil == 3) {
					bilString = "3+";
				}
				break;
			case 4:// 酮体
				int ket = Integer.parseInt(niaoYeBuffer[i]);
				if (ket == 0) {
					ketString = "-";
				} else if (ket == 1) {
					ketString = "+-";
				} else if (ket == 2) {
					ketString = "1+";
				} else if (ket == 3) {
					ketString = "2+";
				} else if (ket == 4) {
					ketString = "3+";
				}
				break;
			case 5:// 葡萄糖
				int glu = Integer.parseInt(niaoYeBuffer[i]);
				if (glu == 0) {
					gluString = "-";
				} else if (glu == 1) {
					gluString = "+-";
				} else if (glu == 2) {
					gluString = "1+";
				} else if (glu == 3) {
					gluString = "2+";
				} else if (glu == 4) {
					gluString = "3+";
				} else if (glu == 5) {
					gluString = "4+";
				}
				break;
			case 6:// 蛋白质
				int pro = Integer.parseInt(niaoYeBuffer[i]);
				if (pro == 0) {
					proString = "-";
				} else if (pro == 1) {
					proString = "+-";
				} else if (pro == 2) {
					proString = "1+";
				} else if (pro == 3) {
					proString = "2+";
				} else if (pro == 4) {
					proString = "3+";
				}
				break;
			case 7:// PH值
				int ph = Integer.parseInt(niaoYeBuffer[i]);
				if (ph == 0) {
					phString = "5";
				} else if (ph == 1) {
					phString = "5.5";
				} else if (ph == 2) {
					phString = "6";
				} else if (ph == 3) {
					phString = "6.5";
				} else if (ph == 4) {
					phString = "7";
				} else if (ph == 5) {
					phString = "7.5";
				} else if (ph == 6) {
					phString = "8";
				} else if (ph == 7) {
					phString = "8.5";
				} else if (ph == 8) {
					phString = "9";
				}
				break;
			case 8:// 亚硝酸盐
				int nit = Integer.parseInt(niaoYeBuffer[i]);
				if (nit == 0) {
					nitString = "-";
				} else if (nit == 1) {
					nitString = "1+";
				}
				break;
			case 9:// 白细胞
				int leu = Integer.parseInt(niaoYeBuffer[i]);
				if (leu == 0) {
					leuString = "-";
				} else if (leu == 1) {
					leuString = "+-";
				} else if (leu == 2) {
					leuString = "1+";
				} else if (leu == 3) {
					leuString = "2+";
				} else if (leu == 4) {
					leuString = "3+";
				}
				break;
			case 10:// 比重
				int sg = Integer.parseInt(niaoYeBuffer[i]);
				if (sg == 0) {
					sgString = "1.000";
				} else if (sg == 1) {
					sgString = "1.005";
				} else if (sg == 2) {
					sgString = "1.010";
				} else if (sg == 3) {
					sgString = "1.015";
				} else if (sg == 4) {
					sgString = "1.020";
				} else if (sg == 5) {
					sgString = "1.025";
				} else if (sg == 6) {
					sgString = "1.030";
				}
				break;
			case 11:// 维生素C
				int asc = Integer.parseInt(niaoYeBuffer[i]);
				if (asc == 0) {
					ascString = "-";
				} else if (asc == 1) {
					ascString = "1+";
				} else if (asc == 2) {
					ascString = "2+";
				} else if (asc == 3) {
					ascString = "3+";
				} else if (asc == 4) {
					ascString = "+-";
				}
				break;
			default:
				break;
			}
		}
		str_result = "尿胆原:" + uroString + ",潜血:" + bloString + ",胆红素:" + bilString + ",酮体:" + ketString + ",葡萄糖:"
				+ gluString + ",蛋白质:" + proString + ",PH:" + phString + ",亚硝酸盐:" + nitString + ",白细胞:" + leuString
				+ ",比重:" + sgString + ",维生素:" + ascString;
		// 验证重复数据
		if (!checkData("蛋白质", proString)) {
			// false 不保存数据
			return str_result;
		}

		UUID uuidNiaoYe = UUID.randomUUID();
		String dateNiaoYe = df.format(new Date());

		// 存尿胆原
		saveCLData("诺安尿液分析仪", "尿液分析仪", "尿胆原", uroString, "尿胆原", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 存潜血
		saveCLData("诺安尿液分析仪", "尿液分析仪", "潜血", bloString, "潜血", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 存胆红素
		saveCLData("诺安尿液分析仪", "尿液分析仪", "胆红素", bilString, "胆红素", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);

		// 存酮体
		saveCLData("诺安尿液分析仪", "尿液分析仪", "酮体", ketString, "酮体", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 葡萄糖
		saveCLData("诺安尿液分析仪", "尿液分析仪", "葡萄糖", gluString, "葡萄糖", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 蛋白质
		saveCLData("诺安尿液分析仪", "尿液分析仪", "蛋白质", proString, "蛋白质", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// PH
		saveCLData("诺安尿液分析仪", "尿液分析仪", "PH", phString, "酸碱度", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 亚硝酸盐
		saveCLData("诺安尿液分析仪", "尿液分析仪", "亚硝酸盐", nitString, "亚硝酸盐", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 白细胞
		saveCLData("诺安尿液分析仪", "尿液分析仪", "白细胞", leuString, "白细胞", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 比重
		saveCLData("诺安尿液分析仪", "尿液分析仪", "比重", sgString, "比重", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 维生素
		saveCLData("诺安尿液分析仪", "尿液分析仪", "维生素", ascString, "维生素", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);

		// HealthTiJian_FzjcFragment.showNiaoYeFenxi(proString, gluString,
		// ketString, bloString);
		return str_result;
	}

	public static String getNiaoYeBLE_EMP_UI(String uroString,String bloString,String bilString,
											 String ketString,String gluString,String proString,
											 String phString, String nitString,String leuString,
											 String sgString,String ascString) {
		// uroString 尿胆原    UBG
		// bloString 潜血      BLD
		// bilString 胆红素    BIL
		// ketString 酮体      KET
		// gluString 葡萄糖    GLU
		// proString 蛋白质    PRO
		// phString ph        PH
		// nitString 亚硝酸盐   NIT
		// leuString 白细胞    LEU
		// sgString 比重       SG
		// ascString 维生素C   VC
		IDCARD = NovaApplication.getUserInfo().getIDCARD();
		str_result = "尿胆原:" + uroString + ",潜血:" + bloString + ",胆红素:" + bilString + ",酮体:" + ketString + ",葡萄糖:"
				+ gluString + ",蛋白质:" + proString + ",PH:" + phString + ",亚硝酸盐:" + nitString + ",白细胞:" + leuString
				+ ",比重:" + sgString + ",维生素:" + ascString;
		// 验证重复数据
//		if (!checkData("蛋白质", proString)) {
//			// false 不保存数据
//			return str_result;
//		}

		UUID uuidNiaoYe = UUID.randomUUID();
		String dateNiaoYe = df.format(new Date());

		//诺安尿液分析仪
		// 存尿胆原
		saveCLData("恩普生", "尿液分析仪", "尿胆原", uroString, "尿胆原", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 存潜血
		saveCLData("恩普生", "尿液分析仪", "潜血", bloString, "潜血", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 存胆红素
		saveCLData("恩普生", "尿液分析仪", "胆红素", bilString, "胆红素", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 存酮体
		saveCLData("恩普生", "尿液分析仪", "酮体", ketString, "酮体", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 葡萄糖
		saveCLData("恩普生", "尿液分析仪", "葡萄糖", gluString, "葡萄糖", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 蛋白质
		saveCLData("恩普生", "尿液分析仪", "蛋白质", proString, "蛋白质", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// PH
		saveCLData("恩普生", "尿液分析仪", "PH", phString, "酸碱度", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 亚硝酸盐
		saveCLData("恩普生", "尿液分析仪", "亚硝酸盐", nitString, "亚硝酸盐", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 白细胞
		saveCLData("恩普生", "尿液分析仪", "白细胞", leuString, "白细胞", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 比重
		saveCLData("恩普生", "尿液分析仪", "比重", sgString, "比重", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		// 维生素
		saveCLData("恩普生", "尿液分析仪", "维生素", ascString, "维生素", uuidNiaoYe.toString(), IDCARD, dateNiaoYe);
		return str_result;
	}

	/**
	 * 保存测量数据
	 * 
	 * @param device_name
	 * @param device_type
	 * @param cl_type
	 * @param cl_value
	 * @param cl_type_name
	 * @param GUID
	 * @param IDCARD
	 * @param cl_time
	 * @author 王婷婷
	 * @date 2017年7月13日 下午5:40:20
	 */
	public static void saveCLData(String device_name, String device_type, String cl_type, String cl_value,
			String cl_type_name, String GUID, String IDCARD, String cl_time) {
		SBCL_DATA sbcl_Data = new SBCL_DATA();
		sbcl_Data.setDEVICE_NAME(device_name);
		sbcl_Data.setDEVICE_TYPE(device_type);
		sbcl_Data.setCL_TYPE(cl_type);
		sbcl_Data.setCL_VALUE(cl_value);
		sbcl_Data.setCL_TYPE_NAME(cl_type_name);
		sbcl_Data.setGUID(GUID);
		sbcl_Data.setIDCARD(IDCARD);
		sbcl_Data.setCL_TIME(cl_time);
		sbcl_Data.setIS_UPDATE("Y");
		NovaApplication.fdbmanger.save(sbcl_Data);
	}

	public static void saveXuetangBj(String valueStr) {
		saveCLDataNew("鱼跃血糖",
				"血糖仪", DeviceEnum.BG.getDeviceType(),
				valueStr,
				"百捷三合一",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveNs(String valueStr) {
		saveCLDataNew("BeneCheck-ns",
				"百捷三合一", "NS",
				valueStr,
				"尿酸",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveDgc(String valueStr) {
		saveCLDataNew("BeneCheck-dgc",
				"百捷三合一", "DGC",
				valueStr,
				"胆固醇",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveTiwen(String valueStr) {
		saveCLDataNew("爱奥乐红外体温计",
				"红外体温计", "AH",
				valueStr,
				"体温",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveTiwen1(String valueStr) {
		saveCLDataNew("鱼跃红外体温计",
				"红外体温计", "AH",
				valueStr,
				"体温",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveTizhong(String valueStr) {
		saveCLDataNew("轻加脂肪秤",
				"脂肪秤", "FM",
				valueStr,
				"体重",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveXueZhi(String valueStr) {
		saveCLDataNew("e家医护血脂",
				"血脂4项", "BF",
				valueStr,
				BluetoothConstant.PW_01DEVICE_NAME,
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveXueyang(String valueStr) {
		saveCLDataNew("科瑞康血氧仪",
				"血氧仪", "BO",
				valueStr,
				BluetoothConstant.PW_01DEVICE_NAME,
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveXueyangyuyue(String valueStr) {
		saveCLDataNew("鱼跃血氧仪",
				"血氧仪", "BO",
				valueStr,
				BluetoothConstant.PW_01DEVICE_NAME,
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveXueyangbeirui(String valueStr) {
		saveCLDataNew("贝瑞血氧仪",
				"血氧仪", "BO",
				valueStr,
				"BerryMed",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveXuetang(String valueStr) {
		saveCLDataNew("三诺血糖仪",
				"血糖仪", "BG",
				valueStr,
				"Sinocare",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveXueya(String valueStr) {
		saveCLDataNew("脉搏波血压计",
				"血压计", "BP",
				valueStr,
				"脉搏波4.0",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveyuyueya(String valueStr) {
		saveCLDataNew("鱼跃血压计",
				"血压计", "BP",
				valueStr,
				"鱼跃血压计",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveChenhaoBp(String valueStr) {
		saveCLDataNew("辰浩血压计",
				"血压计", "BP",
				valueStr,
				"辰浩4.0",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveEcg(String valueStr) {
		saveCLDataNew("PC80B心电",
				"心电", "ECG",
				valueStr,
				"PC80B心电",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveUE(String valueStr) {
		saveCLDataNew("恩普生",
				"尿液分析仪", "UE",
				valueStr,
				"尿液分析仪",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void savePEF(String valueStr) {
		saveCLDataNew("肺功能",
				"肺功能", "PEF",
				valueStr,
				"肺功能",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveWaist(String valueStr) {
		saveCLDataNew("腰臀比",
				"腰臀比", "WAIST",
				valueStr,
				"腰臀比",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	// 人体成分
	public static void saveCop(String valueStr) {
		saveCLDataNew("人体成分",
				"人体成分", "RTCF_DH",
				valueStr,
				"人体成分",
				UUID.randomUUID().toString(),
				NovaApplication.getUserInfo().getIDCARD(),
				TimeUtils.date2String(new Date(),"yyyy-MM-dd HH:mm:ss"));
	}

	public static void saveCLDataNew(String device_name, String device_type, String cl_type, String cl_value,
								  String cl_type_name, String GUID, String IDCARD, String cl_time) {
		SBCL_DATA_NEW sbcl_Data = new SBCL_DATA_NEW();
		sbcl_Data.setDEVICE_NAME(device_name);
		sbcl_Data.setDEVICE_TYPE(device_type);
		sbcl_Data.setCL_TYPE(cl_type);
		sbcl_Data.setCL_VALUE(cl_value);
		sbcl_Data.setCL_TYPE_NAME(cl_type_name);
		sbcl_Data.setGUID(GUID);
		sbcl_Data.setIDCARD(IDCARD);
		sbcl_Data.setCL_TIME(cl_time);
		sbcl_Data.setIS_UPDATE("Y");
		NovaApplication.fdbmanger.save(sbcl_Data);
		// 上传数据到新平台

		try {
			TjDataUpload tjDataUpload = new TjDataUpload();
			tjDataUpload.uploadData();
		} catch (Exception e) {
			e.printStackTrace();
		}

//		SbclDataUpload.uploadSbclDataNew();
	}

	/**
	 * 验证数据
	 * 
	 * @author 王婷婷
	 * @date 2017年4月11日 下午4:48:40
	 */
	private static boolean checkData(String cltype, String data) {
		boolean flag = true;
		List<SBCL_DATA> sbcl_data = NovaApplication.fdbmanger.findAllByWhere(SBCL_DATA.class,
				"IDCARD='" + IDCARD + "' and CL_TYPE='" + cltype + "'");

		if (sbcl_data.size() > 0) {
			String date_pre = sbcl_data.get(sbcl_data.size() - 1).getCL_TIME();
			String data_pre = sbcl_data.get(sbcl_data.size() - 1).getCL_VALUE();
			if (!TextUtils.isEmpty(date_pre)) {
				Log.w(TAG, date_pre);
				try {
					long time_sec = ((new Date()).getTime() - (df.parse(date_pre)).getTime()) / 1000;
					Log.w(TAG + time_sec, "tt" + time_sec);

					if (cltype.equals(BluetoothConstant.NIAOJI_HT111A_HANTANG)) {
						// 测量类型是尿机,小于5S不用验证数据结果
						if (time_sec <= 5) {
							flag = false;
						}
					} else {
						if (time_sec <= 3 && data_pre.equals(data)) {
							// 测量类型是血糖、血氧,小于3S验证数据结果
							flag = false;
						}
					}

				} catch (ParseException e) {
					e.printStackTrace();
					flag = false;
				}
			}

		}

		return flag;
	}

}
